
from homeassistant.const import (ATTR_ENTITY_ID,ATTR_FRIENDLY_NAME,ATTR_DOMAIN)

from .const import (
    SET_COLOR ,
    NULL_VALUE ,
    SET_COLOR_TEMPERATURE ,
    SET_BRIGHTNESS 
)

def get_props(cur_dev,dev):
        """返回开关属性"""
        if dev['name'] == 'power':
            dev['value']  = cur_dev['state']
        else:
            dev['value'] = NULL_VALUE
        return dev



def set_props_to_call_service_data(cur_dev,dev):
    """设置开关"""
    domain = cur_dev[ATTR_ENTITY_ID].split('.')[0]
    service = 'turn_on' if dev['value'] == 'on' else 'turn_off'
    data = {}
    if dev['name'] == 'power':
        data = {ATTR_ENTITY_ID:cur_dev[ATTR_ENTITY_ID]}
        
    return [domain,service,data]